package org.elanfox.intellicommunity.biz.dto.msg;

import lombok.Data;
import org.elanfox.intellicommunity.biz.entity.msg.AlarmMsgGroupPO;
import org.elanfox.intellicommunity.common.utils.Jsr310Utils;
import org.elanfox.intellicommunity.data.base.dto.BaseDTO;

/**
 * @author allan
 * @version 1.0.0
 * @date 2020/3/15
 */
@Data
public class AlarmGroupDTO implements BaseDTO {
    private static final long serialVersionUID = -7408384779282803635L;
    private String alarmType;
    private Long groupId;
    private Integer userId;
    private String username;
    private String userTypeDesc;
    private String createTime;
    private String updateTime;
    private String alarmStatus;

    private String address;
    private Long locatorId;

    public AlarmGroupDTO(AlarmMsgGroupPO alarmMsgGroupPO) {
        this.alarmType = alarmMsgGroupPO.getAlarmType().getDesc();
        this.groupId = alarmMsgGroupPO.getGroupId();
        this.userId = alarmMsgGroupPO.getUserId();
        this.username = alarmMsgGroupPO.getUserName();
        this.userTypeDesc = alarmMsgGroupPO.getUserType().getDesc();
        this.createTime = Jsr310Utils.DateTime.asString(alarmMsgGroupPO.getCreateTime());
        this.updateTime = Jsr310Utils.DateTime.asString(alarmMsgGroupPO.getUpdateTime());
        this.address = alarmMsgGroupPO.getAlarmMsgPOS().get(0).getLocatorInfo().getAddress();
        this.locatorId = alarmMsgGroupPO.getAlarmMsgPOS().get(0).getLocatorId();
        this.alarmStatus = alarmMsgGroupPO.getAlarmStatus().getDesc();
    }
}
